n, m = map(int, input().split())
a = [[]] * 110
for i in range(n):
    s = input().split()
    a[i] = [int(x) for x in s]
for i in range(n):
    for j in range(m):
        if i == 0 or i == n - 1 or j == 0 or j == m - 1:
            print(a[i][j], end=" ")
        else:
            x = round((a[i][j] + a[i - 1][j] +
                       a[i + 1][j] + a[i][j - 1] + a[i][j + 1]) / 5)
            print(x, end=" ")
            pass
    print(end="\n")
